package cn.edu.scau.dao;

import cn.edu.scau.entity.Booking;
import java.math.BigDecimal;

import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

@Mapper
@CacheNamespace
public interface BookingMapper {
    @Delete({
        "delete from booking",
        "where bookingID = #{bookingid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer bookingid);

    @Insert({
        "insert into booking (bookingID, bookingprepayamount)",
        "values (#{bookingid,jdbcType=INTEGER}, #{bookingprepayamount,jdbcType=DECIMAL})"
    })
    @Options(useGeneratedKeys = true,keyColumn = "bookingID",keyProperty = "bookingid")
    int insert(Booking record);

    @Options(useGeneratedKeys = true,keyColumn = "bookingID",keyProperty = "bookingid")
    @InsertProvider(type=BookingSqlProvider.class, method="insertSelective")
    int insertSelective(Booking record);

    @Select({
        "select",
        "bookingID, bookingprepayamount",
        "from booking",
        "where bookingID = #{bookingid,jdbcType=INTEGER}"
    })
    
    Booking selectByPrimaryKey(Integer bookingid);

    @UpdateProvider(type=BookingSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Booking record);

    @Update({
        "update booking",
        "set amount = #{bookingprepayamount,jdbcType=DECIMAL}",
        "where bookingID = #{bookingid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Booking record);
}